/* rewoiqa.p - WIP STATUS INQUIRY SUBPROGRAM FOR WIP LOT TRACE                */
/* Copyright 1986-2011 QAD Inc., Santa Barbara, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Id:: rewoiqa.p 2366 2010-11-10 01:47:19Z zzh                           $: */
/*                                                                            */
/* REVISION: 9.1          CREATED: 01/01/99     BY: *N002* Steve Nugent       */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00     BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1    LAST MODIFIED: 07/24/00     BY: *N0GS* Bill Gates         */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00     BY: *N0KP* Mark Brown         */
/* Revision: 1.20    BY: Paul Donnelly (SB)       DATE: 06/28/03  ECO: *Q00K* */
/* Revision: 1.21  BY: Robin McCarthy           DATE: 06/30/06  ECO: *R04J* */
/* $Revision: 1.22 $  BY: Namita Patil             DATE: 03/13/08  ECO: *P6NS* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/*-Revision end---------------------------------------------------------------*/

{us/bbi/mfdeclre.i}
{us/bbi/gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input parameter ip_id like wr_lot no-undo.
define input parameter ip_op like wr_op no-undo.
define input parameter ip_um like pt_um no-undo.

define variable i            as integer no-undo.
define variable queue        as character no-undo.
define variable dummy        as character no-undo.
define variable routing_code as character no-undo.
define variable effdate      as date no-undo.

{us/wl/wlcon.i}

form with frame b down width 80.

for each wld_det no-lock
      where wld_det.wld_domain = global_domain
      and wld_alloc_id         = ip_id
      and wld_alloc_op         = ip_op
      and wld_qty              <> 0:

   pause 0.

   /* GET LANGUAGE MNEMONIC FOR DISPLAY */

   {us/gp/gplngn2a.i
      &file='wld_det'
      &field='wld_alloc_que'
      &code=wld_alloc_que
      &mnemonic=queue
      &label=dummy}

   do with frame b:
      /* SET EXTERNAL LABELS */
      setFrameLabels(frame b:handle).
      display
         queue @ wld_alloc_que
         wld_prodby_op when(wld_alloc_que = REJECT_QUEUE)
         wld_wkctr 
         wld_mch
         wld_lotser
         wld_ref
         wld_qty
         ip_um
      with frame b down width 80 title color normal
         (getFrameTitle("WIP_LOT_INVENTORY",25)).

      down 1 with frame b.
   end. /* do with */

   i = i + 1.
end. /* FOR EACH wld_det */

{us/bbi/gprun.i ""wlgeteff.p""
         "(output effdate) no-error"}

if effdate = ?
then
   effdate = today.

for first wo_mstr
   where wo_mstr.wo_domain = global_domain
   and   wo_lot            = ip_id
no-lock:
end. /* FOR FIRST wo_mstr */

routing_code = if wo_routing = ''
               then
                  wo_part
               else
                  wo_routing.

for last wlrm_mstr
   where wlrm_mstr.wlrm_domain =  global_domain
   and  (wlrm_routing          =  routing_code
   and (wlrm_start            <= effdate or
        wlrm_end               =  ?)
       )
   no-lock:
end. /* FOr LAST wlrm_mstr */

if not available wlrm_mstr
then
   for first wlrm_mstr
      where wlrm_mstr.wlrm_domain = global_domain
      and  (wlrm_routing          = routing_code
      and   wlrm_start            = ?
      and  (wlrm_end             >= effdate or
            wlrm_end              = ?)
           )
      no-lock:
   end.

if available wlrm_mstr
then do:
   if wlrm_trc_parent and i = 0 then do:
      /* NO WIP LOTS FOUND FOR THIS OPERATION */
      {us/bbi/pxmsg.i &MSGNUM=8425 &ERRORLEVEL=1}
   end. /* IF wlrm_trc_parent */
end. /* IF AVAILABLE wlrm_mstr */
else do:
   for first wlc_ctrl
      where wlc_ctrl.wlc_domain = global_domain
   no-lock:
   end.
   if wlc_trc_parent
       and i = 0
   then do:
      /* NO WIPLOTS FOUND FOR THIS OPERATION */
      {us/bbi/pxmsg.i &MSGNUM=8425 &ERRORLEVEL=1}

   end. /* IF wlc_trc_parent */
end. /* IF NOT AVAILABLE wlrm_mstr */
